﻿//-------------------------------------
// WBFSSync - WBFSSync.exe
//
// Copyright 2009 Caian (ÔmΣga Frøst) <frost.omega@hotmail.com>
//
// WBFSSync is Licensed under the terms of the Microsoft Reciprocal License (Ms-RL)
//
// WinDrive.cs:
//
// Implementação da interface que guarda informações sobre dispositivos de armazenagem conectados ao computador
// específica para Drives com sistemas de arquivos reconhecidos pelo Windows
//
//-------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace WBFSSync
{
    public class WinDrive : IDrive
    {
        public DriveInfo _Drive = null;
        public DriveFlags _Flags = DriveFlags.Unknown;
        
        long transfer = 0;
        int numoperations = 0;

        public string Name { get { try{return _Drive.Name.ToUpper();}catch{return "?";} } }
        public string Label { get { try { return _Drive.VolumeLabel; } catch { return ""; } } }
        public DriveFlags Flags { get { return _Flags; } }

        public bool Ready { get { try { return _Drive.IsReady; } catch { return false; } } }

        public long Size { get { try { return _Drive.TotalSize; } catch { return -1; } } }
        public long FreeSpace { get { try { return _Drive.AvailableFreeSpace; } catch { return -1; } } }
        public long UsedSpace { get { try { return _Drive.TotalSize - _Drive.TotalFreeSpace; } catch { return -1; } } }
        public long ReservedSpace { get { return transfer; } set { transfer = Math.Max(value, 0); } }

        public bool Is(DriveFlags flag) { return (_Flags & flag) != DriveFlags.Unknown; }

        public Int32 ActiveOperations { get { return numoperations; } set { numoperations = value; } }

        public int Open(Char d)
        {
            return -1;
        }

        public void Close()
        {
        }

        public void Refresh()
        {
        }
    }
}
